package br.com.gscorp.bankLion.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.domain.Sort.Order;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import br.com.gscorp.bankLion.entity.Banco;
import br.com.gscorp.bankLion.repository.BancoRepository;

@Controller
@Transactional
@RequestMapping("/banco")
public class BancoController {
	
	@Autowired
	private BancoRepository repository;
	
	@RequestMapping(method=RequestMethod.GET)
	@ResponseBody
	public List<Banco> listar(){
		return (List<Banco>) repository.findAll(new Sort(new Order(Direction.ASC, "nome")));
	}
}
